package com.jxs.android.weiget;

import java.util.List;

import android.content.Context;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jxs.android.ges.R;
import com.jxs.android.ges.data.A_Case_AttrachMent.FileInfo;

public class BuCommonTableView_AttachMent_Item extends LinearLayout {

	private TextView index,// 序号
			remark_contentd,// 业务类型
			add_dated,// 用户数
			down_load_url;// 存量收入

	public BuCommonTableView_AttachMent_Item(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public BuCommonTableView_AttachMent_Item(Context context) {
		this(context, null);
		init(context);
	}

	private void init(Context context) {
		LayoutInflater.from(context).inflate(R.layout.bu_table_view_attachment_item, this);

		index = (TextView) findViewById(R.id.index);
		remark_contentd = (TextView) findViewById(R.id.remark_contentd);
		add_dated = (TextView) findViewById(R.id.add_dated);
		down_load_url = (TextView) findViewById(R.id.down_load_url);
	}

	public void setBackgroud(int resid) {
		index.setBackgroundResource(resid);
		remark_contentd.setBackgroundResource(resid);
		add_dated.setBackgroundResource(resid);
		down_load_url.setBackgroundResource(resid);
	}

	public void setTextColor(int resid) {
		index.setTextColor(resid);
		remark_contentd.setTextColor(resid);
		add_dated.setTextColor(resid);
		down_load_url.setTextColor(resid);
	}

	public void setValue(String i_index, String i_remark_contentd, String i_add_dated, String i_down_load_url) {
		index.setText(i_index);
		remark_contentd.setText(i_remark_contentd);
		add_dated.setText(i_add_dated);
		down_load_url.setText(i_down_load_url);
	}

	public void setValue(String i_index, String i_remark_contentd, String i_add_dated, List<FileInfo> fileLists) {
		index.setText(i_index);
		remark_contentd.setText(i_remark_contentd);
		add_dated.setText(i_add_dated);

		StringBuilder i_down_load_url = new StringBuilder("");
		if (null != fileLists && !fileLists.isEmpty()) {
			for (FileInfo fileInfo : fileLists) {
				i_down_load_url.append("<a href=\"" + fileInfo.down_url + "\">");
				i_down_load_url.append(fileInfo.file_name);
				i_down_load_url.append("</a> (" + fileInfo.formatFileSize + ")<br/>");
			}

		}
		down_load_url.setText(Html.fromHtml(i_down_load_url.toString()));
		down_load_url.setClickable(true);
		down_load_url.setMovementMethod(LinkMovementMethod.getInstance());

	}

	public void setremark_contentdGravityCenter() {
		remark_contentd.setGravity(Gravity.CENTER);
	}

}